#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

static bool prime(uint64_t n) {
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;
    if (n < 2)
        return false;
    for (uint64_t i = 3; i * i <= n; i += 2)
        if (n % i == 0)
            return false;
    return true;
}

static bool truncatable_prime(uint64_t a) {
    int b = a;

    while (a) {
        if (!prime(a))
            return false;
        a /= 10;
    }

    int c = 1;
    while (c < b)
        c *= 10;
    for (b = b % c; b; c /= 10, b %= c) {
        if (!prime(b))
            return false;
    }
    return true;
}

static bool vector_display(const vector<uint64_t>& a) {
    for (auto e : a)
        cout << e << " ";
    cout << endl;
    return true;
}

int main() {
    vector<uint64_t> a;
    for (uint64_t i = 11; a.size() < 11; i += 2) {
        if (truncatable_prime(i)) {
            a.push_back(i);
            vector_display(a);
        }
    }
    cout << accumulate(a.begin(), a.end(), 0) << endl; // 748317
}